package main

import (
	"fmt"
	"gin/controller"
	"gin/tool"
	"github.com/gin-gonic/gin"
)

func main() {
	//读取配置文件
	cfg, err := tool.ParseConfig("./config/app.json")
	if err != nil {
		fmt.Println("---------main config get error--------------")
		return
	}
	_, errMysql := tool.OrmEngine(cfg)
	if errMysql != nil {
		fmt.Println("----------数据库链接失败1---------")
	}
	app := gin.Default()
	registerRouter(app) //路由注册
	defer tool.RedisCon.Close()
	_ = app.Run(cfg.AppHost + ":" + cfg.AppPort)
}

func registerRouter(router *gin.Engine) {
	new(controller.IndexController).Router(router)
	new(controller.MemberController).Router(router)
	new(controller.FileUploadController).Router(router)
	new(controller.GoodsController).Router(router)

}
